function [output_1,output_2,output_3,output_4,output_5] = runparallelcode(input,beta,gamma)
convergence_text = 'y';

[f,J] = create_func();
f_obj = [0;0];

results = struct();

k = 1;
epsilon = 0.000001;
max_iter = 100;

% u = [1;0;0]; % initial input
u = [1;2;1];

results(k).u = u;
results(k).u_l1norm = norm(u,1);
results(k).f = f(u(1),u(2),u(3));
results(k).J = J(u(1),u(2),u(3));
results(k).g = results(k).f - f_obj;
results(k).g_l1norm = norm(results(k).g,1);

adaptive = 'true';
% adaptive = 'false';
% beta = 0.3;
% c_0 = 1.0;
c_max = 2*(1+beta)/(1-beta);
% gamma = 0.9;
h = 0.5;

mmt = zeros(size(u));

ME = 0;

while results(k).g_l1norm > epsilon
    if k <= max_iter
        
        if strcmp(adaptive,'true')
            c_0 = 1 + (c_max-1)*gamma^k;
        end
        
        % try
            calc_w
        % catch ME
        %     u = NaN;
        %     break
        % end
        mmt = beta*mmt + (1-beta)*w;
        u = u - 1.0*mmt;

        k = k+1;
        results(k).u = u;
        results(k).u_l1norm = norm(u,1);
        results(k).f = f(u(1),u(2),u(3));
        results(k).J = J(u(1),u(2),u(3));
        results(k).g = results(k).f - f_obj;
        results(k).g_l1norm = norm(results(k).g,1);

        % pause(0.01)
    else
        convergence_text = 'n';
        break
    end
end

% if results(k).g_l1norm < 0.01
%     close all
%     find_solution
% end

if isnan(u) == 1
    convergence_text = 'NaN';
end

save("./temp_progress/"+ string(input) + ', ' + convergence_text,"u")


output_1 = results;
output_2 = results(k).u_l1norm;
output_3 = convergence_text;
if strcmp(convergence_text,'y')
    theta = atan2(u(2),u(1));
    if theta < 0
        theta = theta + 2*pi;
    end
    output_4 = round(theta/(pi/2)+1);
    if output_4 == 5
        output_4 = 1;
    end
else
    output_4 = 0;
end
output_5 = k;

end